import __builtin__
import os
import sys
-import imp
+#import imp
-def main_is_frozen():
- return (hasattr(sys, "frozen") or # new py2exe
- hasattr(sys, "importers") # old py2exe
- or imp.is_frozen("__main__")) # tools/freeze
-
-#if not main_is_frozen():
-# try:
-# import wxversion
-# wxversion.select("2.6")
-# except:
-# wxversion.select("2.8")
-
-def get_main_dir():
- if main_is_frozen():
- return os.path.dirname(sys.executable)
- return os.path.dirname(os.path.abspath(__file__))
-__builtin__.get_main_dir = get_main_dir
-__builtin__.GPDF2SWF_BASEDIR = get_main_dir()
-
-pyver = "".join(map(str, sys.version_info[0:2]))
-#print >>sys.stderr, pyver
-if main_is_frozen():
- sys.path.insert(0, os.path.join("..", "python%s" % pyver))
-else:
- sys.path.insert(0, os.path.join("..", "lib", "python"))
- sys.path.insert(1, os.path.join("..", "python%s" % pyver))
+#def main_is_frozen():
+# return (hasattr(sys, "frozen") or # new py2exe
+# hasattr(sys, "importers") # old py2exe
+# or imp.is_frozen("__main__")) # tools/freeze
+#
+##if not main_is_frozen():
+## try:
+## import wxversion
+## wxversion.select("2.6")
+## except:
+## wxversion.select("2.8")
+#
+#def get_main_dir():
+# if main_is_frozen():
+# return os.path.dirname(sys.executable)
+# return os.path.dirname(os.path.abspath(__file__))
+#__builtin__.get_main_dir = get_main_dir
+#__builtin__.GPDF2SWF_BASEDIR = get_main_dir()
+#
+#pyver = "".join(map(str, sys.version_info[0:2]))
+##print >>sys.stderr, pyver
+#if main_is_frozen():
+# sys.path.insert(0, os.path.join("..", "python%s" % pyver))
+#else:
+# sys.path.insert(0, os.path.join("..", "lib", "python"))
+# sys.path.insert(1, os.path.join("..", "python%s" % pyver))
import wx
#print >>sys.stderr, wx.VERSION
from lib.app import Pdf2Swf
+__builtin__.GPDF2SWF_BASEDIR = os.path.dirname(os.path.abspath(sys.argv[0]))
+
if __name__ == "__main__":
+ #print "sys.argv[0]", sys.argv[0]
+ #print "abspath sys.argv[0]",
+ #print "sys.executable", sys.executable
+ #print "abspath sys.executable", os.path.abspath(sys.executable)
+ #print "GPDF2SWF_BASEDIR", GPDF2SWF_BASEDIR
app = wx.App(False)
app.SetAppName(u"gpdf2swf")
Pdf2Swf()
choices=["everything to bitmaps",
"fonts to fonts, everything else to bitmaps",
"polygons to polygons and fonts to fonts"],
- size=(350,-1), style=wx.CB_DROPDOWN
+ size=(350,-1)
)
# I'm not sure about the utility of this, so Show False
self.toolbar_preview_type.Show(False)
import os
import wx
import operator
-#import imp
+import imp
from lib.wordwrap import wordwrap
from gui.boldstatictext import BoldStaticText
import viewers
import gui.fields
+
+# this two are only to satisfy some plugins requirements
import gui.plugin
+import shutil
-import viewers.raw
-import viewers.simple
-import viewers.rfx
-import viewers.flexpaper
-import viewers.technoargia
+#import viewers.raw
+#import viewers.simple
+#import viewers.rfx
+#import viewers.flexpaper
+#import viewers.technoargia
class Viewers:
def __init__(self):
- self.viewers = [
- 'raw',
- 'simple',
- 'rfx',
- 'flexpaper',
- 'technoargia',
- ]
- self.modules = [
- viewers.raw,
- viewers.simple,
- viewers.rfx,
- viewers.flexpaper,
- viewers.technoargia,
- ]
+ #self.viewers = [
+ # 'raw',
+ # 'simple',
+ # 'rfx',
+ # 'flexpaper',
+ # 'technoargia',
+ #]
+ self.viewers = []
+ #self.modules = [
+ # viewers.raw,
+ # viewers.simple,
+ # viewers.rfx,
+ # viewers.flexpaper,
+ # viewers.technoargia,
+ #]
+ self.modules = []
- #self.list_viewers()
- #self.import_viewers()
-
- #def list_viewers(self):
- # for file in os.listdir('viewers'):
- # if (file.startswith('.') or file.startswith('_')
- # or file.endswith(".pyc") or not file.endswith('.py')):
- # continue
- # self.viewers.append(os.path.splitext(file)[0])
-
- #def import_viewers(self):
- # for file in self.viewers:
- # try:
- # _temp = imp.load_source("viewers.%s" % file, os.path.join(os.getcwdu(), "viewers/%s.py" % file))
- # self.modules.append(_temp)
- # except:
- # print "Could not load %s" % file
+ self.list_viewers()
+ self.import_viewers()
+
+ def list_viewers(self):
+ for file in os.listdir('viewers'):
+ if (file.startswith('.') or file.startswith('_')
+ or file.endswith(".pyc") or not file.endswith('.py')):
+ continue
+ self.viewers.append(os.path.splitext(file)[0])
+
+ def import_viewers(self):
+ for file in self.viewers:
+ try:
+ _temp = imp.load_source("viewers.%s" % file, os.path.join(os.getcwdu(), "viewers/%s.py" % file))
+ self.modules.append(_temp)
+ except Exception, e:
+ print "Could not load %s (%s)" % (file, e)
#print 'basedir', basedir
opj = os.path.join
- locations = [os.path.normpath(opj(basedir, '..', prog))]
+ locations = [
+ os.path.normpath(opj(basedir, prog)),
+ os.path.normpath(opj(basedir, "..", "src", prog)),
+ ]
if "wxMSW" in wx.PlatformInfo:
try:
system_drive = os.environ['SYSTEMDRIVE']
opj("c:", os.sep, "swftools", prog),
opj("c:", os.sep, "Program Files", "SWFTools", prog),
opj(system_drive, os.sep, program_files, "SWFTools", prog),
- opj(basedir, prog),
])
else:
locations.extend([
self.view.statusbar.btn_cancel.Bind(wx.EVT_BUTTON,
self.OnThumbnailCancel)
+ # Don't know where the problem is (python/xpython or wxwidgets/wxpython)
+ # but I found that this hack was necessary to avoid the app enter in a
+ # idle state. We must, for example, move the mouse inside the app
+ # for threads continue their job.
+ # There is no need for this when freezing with other utils, like
+ # py2exe, pyinstaller, cxfreeze
+ if "wxMSW" in wx.PlatformInfo:
+ self.timer = wx.Timer(self.view)
+ self.view.Bind(wx.EVT_TIMER, lambda evt: None)
+ self.timer.Start(50)
+
def OnFilesDroped(self, evt):
dlg = wx.MessageDialog(self.view,
u"You must drop only one file.",
html_template = open('viewers/flexpaper/FlexPaperViewer.html').read()
from gui.plugin import Plugin
-import os
+import os, sys
class FlexPaper(Plugin):
def __init__(self, swf, filename):
htmlfilename = self._swap_extension(self.__filename, "html")
f = open(htmlfilename, "wb")
- try:
- f.write(html_template % template_vars)
- except Exception, e:
- print e
+ f.write(html_template % template_vars)
f.close()
import shutil
opj = os.path.join
- src = opj(os.path.dirname(__file__), 'flexpaper')
+ basedir = GPDF2SWF_BASEDIR
+ src = opj(basedir, 'viewers', 'flexpaper')
dst = os.path.dirname(self.__filename)
shutil.copy(opj(src, 'FlexPaperViewer.swf'), dst)
"""
from gui.plugin import Plugin
-import os
+import os, sys
class Rfx(Plugin):
def __init__(self, swf, filename):
setattr(self, "_%s" % opt.name, opt.value)
def after_save(self, page):
- viewerfilename = self._swap_extension(__file__, "swf", self._flashversion)
+ basedir = GPDF2SWF_BASEDIR
+ viewerfilename = os.path.join(basedir,
+ "viewers",
+ "rfx%s.swf" % self._flashversion)
self.swfcombine(
u"%s" % viewerfilename,
"""
from gui.plugin import Plugin
-import os
+import os, sys
class Technoargia(Plugin):
def __init__(self, swf, filename):
setattr(self, "_%s" % opt.name, opt.value)
def after_save(self, page):
- viewerfilename = self._swap_extension(__file__, "swf")
+ basedir = GPDF2SWF_BASEDIR
+ viewerfilename = os.path.join(basedir,
+ "viewers",
+ "technoargia.swf")
self.swfcombine(
u"%s" % viewerfilename,